﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace erse253_homework
{
    public partial class CrossValidation : Form
    {
        double[,] data;

        public CrossValidation(double[,] dataTable)
        {
            InitializeComponent();
            //CreateTable(dataTable);
            data = dataTable;
        }


        public CrossValidation(double[,] dataTable, bool show)
        {
            InitializeComponent();
            CreateTable(dataTable);
            data = dataTable;
        }


        public CrossValidation(double[,] dataTable1, double[,] dataTable2, double[,] dataTable3, double[,] dataTable4)
        {
            InitializeComponent();
            //CreateTable(dataTable);
            data = dataTable1;
        }


        private void CreateTable(double[,] dataTable)
        {
            DataTable table = new DataTable("Cross Correlation");

            for (int i = 0; i < dataTable.GetLength(0); i++)
                table.Columns.Add((i + 1).ToString());

            for (int i = 0; i < dataTable.GetLength(1); i++)
                table.Rows.Add();

            for (int i = 0; i < dataTable.GetLength(0); i++)
                for (int j = 0; j < dataTable.GetLength(1); j++)
                    table.Rows[j][i] = dataTable[i, j];


            dataGridView.DataSource = table;

            dataGridView.Update();
        }

        private void meanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NumericalSolutions solution = new NumericalSolutions();
            MessageBox.Show("Mean: " + Math.Round(solution.Mean(data), 4).ToString());
        }

        private void stdToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NumericalSolutions solution = new NumericalSolutions();
            MessageBox.Show("Std Deviation: " + Math.Round(solution.StdDeviationMean(data), 4).ToString());
        }

        private void maxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NumericalSolutions solution = new NumericalSolutions();
            MessageBox.Show("Max: " + Math.Round(solution.Max(data), 4).ToString());
        }

        private void minToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NumericalSolutions solution = new NumericalSolutions();
            MessageBox.Show("Min: " + Math.Round(solution.Min(data), 4).ToString());
        }

        private void cVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NumericalSolutions solution = new NumericalSolutions();
            MessageBox.Show("Coefficient of variation: " + Math.Round(solution.CoefficienfVariation(data), 4).ToString());
        }

        private void coefficientOfSkewnessToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NumericalSolutions solution = new NumericalSolutions();
            MessageBox.Show("Coefficient of skewness: " + Math.Round(solution.CoefficienfSkeness(data), 4).ToString());
        }

    }
}
